<template>
  <div>
    <el-form label-width="80px" :model="account" ref="roleForm">
      <el-form-item label="账号" prop="username">
        <el-input v-model="account.username"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="password">
        <el-input type="password" v-model="account.password"></el-input>
      </el-form-item>
      <el-form-item label="角色" prop="roleId">
        <el-select v-model="account.roleId" placeholder="请选择角色" clearable>
          <el-option
            v-for="item in roleList"
            :key="item.objectId"
            :label="item.roleName"
            :value="item.objectId"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" size="default" @click="handleSubmit">
          注册账号
        </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { userReg, roleGet } from "@/api/user";
export default {
  props: ["row"],
  data() {
    return {
      account: {
        username: "",
        password: "",
        roleId: "",
      },
      roleList: [],
    };
  },
  methods: {
    handleSubmit() {
      userReg(this.account);
    },
  },
  created() {
    roleGet().then((res) => {
      this.roleList = res.data.results;
    });
  },
};
</script>
